package ua.kpi_java_training5.alekseenko.src.module2;

/**
 * Author: Aleksey Alekseenko
 * Date: 10.06.13
 */
public class VictimForTest extends Fish {
    public VictimForTest() {
        this.eatable = true;
    }

    public VictimForTest(int x, int y) {
        this.position.x = x;
        this.position.y = y;
        this.eatable = false;
    }

    @Override
    public void move(int step) {
        boolean untilFishIsInAquarium;
        do {
            untilFishIsInAquarium = false;
            switch (Direction.DOWN) {
                case LEFT:
                    if (this.position.x - step >= 0) {
                        this.position.x -= step;
                    } else {
                        untilFishIsInAquarium = true;
                    }
                    break;

                case RIGHT:
                    if (this.position.x + step <= aquarium.getLength()) {
                        this.position.x += step;
                    } else {
                        untilFishIsInAquarium = true;
                    }
                    break;

                case DOWN:
                    if (this.position.y - step >= 0) {
                        this.position.y -= step;
                    } else {
                        untilFishIsInAquarium = true;
                    }
                    break;

                case UP:
                    if (this.position.y + step <= aquarium.getHeight()) {
                        this.position.y += step;
                    } else {
                        untilFishIsInAquarium = true;
                    }
                    break;
            }
        } while (untilFishIsInAquarium);
    }
}